home *** CD-ROM | disk | FTP | other *** search
/ Champak 145 / (Vol 145) Dec 21 2011.iso / Games / hearts.swf / scripts / DefineSprite_638 / frame_1 / DoAction_13.as < prev    next >
Encoding:
Text File  |  2011-12-21  |  10.2 KB  |  397 lines

  1. this.onEnterFrame = function()
  2. {
  3.    var t = this;
  4.    if(t.mainDisplay.genListBox == true)
  5.    {
  6.       t.mainDisplay.updateListBox();
  7.    }
  8.    if(t.fade == "in")
  9.    {
  10.       if(t.loopvolume < t.initLoopVolume)
  11.       {
  12.          t.loopvolume += 5;
  13.          t.loop.setVolume(t.loopvolume);
  14.       }
  15.       else if(t.loopvolume > t.initLoopVolume)
  16.       {
  17.          t.loopvolume = t.initLoopVolume;
  18.          t.loop.setVolume(t.loopvolume);
  19.       }
  20.    }
  21.    else if(t.fade == "out")
  22.    {
  23.       if(t.loopvolume > 0)
  24.       {
  25.          t.loopvolume -= 5;
  26.          t.loop.setVolume(t.loopvolume);
  27.       }
  28.       else if(t.loopvolume < 0)
  29.       {
  30.          t.loopvolume = 0;
  31.          t.loop.setVolume(t.loopvolume);
  32.       }
  33.    }
  34.    if(t.gamePlay == true)
  35.    {
  36.       if(t.pause == false)
  37.       {
  38.          t.timer = t.timer + 1;
  39.          if(Key.isDown(t.dKey))
  40.          {
  41.             if(t.launcher.my < t.launcher.maxS)
  42.             {
  43.                t.launcher.my += t.launcher.acc;
  44.                if(t.launcher.my > t.launcher.maxS)
  45.                {
  46.                   t.launcher.my = t.launcher.maxS;
  47.                }
  48.             }
  49.          }
  50.          else if(Key.isDown(t.uKey))
  51.          {
  52.             if(t.launcher.my > - t.launcher.maxS)
  53.             {
  54.                t.launcher.my -= t.launcher.acc;
  55.                if(t.launcher.my < - t.launcher.maxS)
  56.                {
  57.                   t.launcher.my = - t.launcher.maxS;
  58.                }
  59.             }
  60.          }
  61.          else
  62.          {
  63.             t.launcher.my *= t.f;
  64.             t.launcher.hoverAng += 5;
  65.             t.launcher.my += Math.sin(t.launcher.hoverAng * t.rc) / 17;
  66.          }
  67.          t.launcher._y += t.launcher.my;
  68.          if(t.launcher._y < t.launcher.hit._height / 2 - t.launcher.hitDy)
  69.          {
  70.             t.launcher._y = t.launcher.hit._height / 2 - t.launcher.hitDy;
  71.             t.launcher.my *= -0.5;
  72.          }
  73.          else if(t.launcher._y > t.stageH - t.launcher.hit._height / 2 - t.launcher.hitDy)
  74.          {
  75.             t.launcher._y = t.stageH - t.launcher.hit._height / 2 - t.launcher.hitDy;
  76.             t.launcher.my *= -0.5;
  77.          }
  78.          if(t.reloading == true)
  79.          {
  80.             ang = 0;
  81.          }
  82.          else
  83.          {
  84.             var dx = t._xmouse - t.launcher._x;
  85.             var dy = t._ymouse - t.launcher._y;
  86.             var ang = Math.atan2(dy,dx) / t.rc;
  87.             if(ang < -70)
  88.             {
  89.                ang = -70;
  90.             }
  91.             else if(ang > 50)
  92.             {
  93.                ang = 50;
  94.             }
  95.          }
  96.          t.curAng += (ang - t.curAng) / 8;
  97.          t.launcher.cupid.body._rotation = t.curAng * 0.3;
  98.          t.launcher.cupid.body.belt._rotation = (- t.curAng) * 0.3;
  99.          if(t.curAng > 40)
  100.          {
  101.             var headAng = 40;
  102.          }
  103.          else
  104.          {
  105.             var headAng = t.curAng;
  106.          }
  107.          t.launcher.cupid.head._rotation = headAng;
  108.          t.launcher.cupid.body.arms._rotation = t.curAng * 0.7;
  109.          t.launcher.cupid.body.arms2._rotation = t.launcher.cupid.body.arms._rotation;
  110.          if(t.curAng < 0)
  111.          {
  112.             var legAng = (- t.curAng) * 0.1;
  113.          }
  114.          else
  115.          {
  116.             var legAng = (- t.curAng) * 0.5;
  117.          }
  118.          t.launcher.cupid.legs._rotation = legAng;
  119.          var i = t.curArrow.length - 1;
  120.          while(i >= 0)
  121.          {
  122.             var n = t.curArrow[i];
  123.             n._rotation = t.curAng + n.ang;
  124.             var point = new Object();
  125.             point.x = t.launcher.cupid.body.arms.tPoint._x;
  126.             point.y = t.launcher.cupid.body.arms.tPoint._y;
  127.             t.launcher.cupid.body.arms.localToGlobal(point);
  128.             n._x = point.x;
  129.             n._y = point.y;
  130.             i--;
  131.          }
  132.          if(t.charge == true)
  133.          {
  134.             if(t.power < t.maxPower)
  135.             {
  136.                t.power += t.chargeS;
  137.                if(t.power > t.maxPower)
  138.                {
  139.                   t.power = t.maxPower;
  140.                }
  141.             }
  142.             t.launcher.powerBar._rotation = t.curAng;
  143.             t.launcher.powerBar.bar._xscale = 100 * t.power / t.maxPower;
  144.          }
  145.          if(t.gameType == "real")
  146.          {
  147.             if(t.htim > t.hdel / t.hmyc)
  148.             {
  149.                t.createHeart();
  150.             }
  151.             else
  152.             {
  153.                t.htim = t.htim + 1;
  154.             }
  155.             if(t.puTim > t.puDel / t.hmyc)
  156.             {
  157.                t.createPU(0);
  158.                t.puTim = 0;
  159.             }
  160.             else
  161.             {
  162.                t.puTim = t.puTim + 1;
  163.             }
  164.          }
  165.          if(t.hmyc != t.inithmyc)
  166.          {
  167.             t.launcher.hSpuTim = t.launcher.hSpuTim + 1;
  168.             if(t.launcher.hSpuTim == t.puHaveMax)
  169.             {
  170.                t.puFunc1(false);
  171.             }
  172.          }
  173.          if(t.grav != t.initGrav)
  174.          {
  175.             t.launcher.gpuTim = t.launcher.gpuTim + 1;
  176.             if(t.launcher.gpuTim == t.puHaveMax)
  177.             {
  178.                t.puFunc2(false);
  179.             }
  180.          }
  181.          if(t.chargeS != t.initChargeS)
  182.          {
  183.             t.launcher.cpuTim = t.launcher.cpuTim + 1;
  184.             if(t.launcher.cpuTim == t.puHaveMax)
  185.             {
  186.                t.puFunc3(false);
  187.             }
  188.          }
  189.          if(t.launcher.maxS != t.launcher.initMaxS)
  190.          {
  191.             t.launcher.mSpuTim = t.launcher.mSpuTim + 1;
  192.             if(t.launcher.mSpuTim == t.puHaveMax)
  193.             {
  194.                t.puFunc4(false);
  195.             }
  196.          }
  197.          if(t.heartSize != t.initHeartSize)
  198.          {
  199.             t.launcher.hSIpuTim = t.launcher.hSIpuTim + 1;
  200.             if(t.launcher.hSIpuTim == t.puHaveMax)
  201.             {
  202.                t.puFunc5(false);
  203.             }
  204.          }
  205.          if(t.numShots != 1)
  206.          {
  207.             t.launcher.tSpuTim = t.launcher.tSpuTim + 1;
  208.             if(t.launcher.tSpuTim == t.puHaveMax)
  209.             {
  210.                t.puFunc7(false);
  211.             }
  212.          }
  213.          t.moveA();
  214.          t.moveH();
  215.          t.moveFly();
  216.       }
  217.    }
  218.    else if(t.gameOver._alpha < 100)
  219.    {
  220.       t.gameOver._alpha += 3;
  221.       if(t.gameOver._alpha > 100)
  222.       {
  223.          t.gameOver._alpha = 100;
  224.       }
  225.    }
  226. };
  227. this.onMouseDown = function()
  228. {
  229.    var t = this;
  230.    if(t.gamePlay == true)
  231.    {
  232.       if(t.pause == false)
  233.       {
  234.          if(t.reloading == false)
  235.          {
  236.             t.charge = true;
  237.             t.beginCharge = false;
  238.             t.launcher.powerBar.gotoAndStop("show");
  239.          }
  240.          else
  241.          {
  242.             t.beginCharge = true;
  243.          }
  244.       }
  245.    }
  246. };
  247. this.onMouseUp = function()
  248. {
  249.    var t = this;
  250.    if(t.gamePlay == true)
  251.    {
  252.       if(t.pause == false)
  253.       {
  254.          if(t.charge == true)
  255.          {
  256.             t.launchArrow(t.power);
  257.             t.power = 0;
  258.             t.charge = false;
  259.             t.curArrow = new Array();
  260.             t.launcher.powerBar.gotoAndStop("blank");
  261.             t.reloading = true;
  262.             t.launcher.cupid.body.arms.anim.gotoAndPlay("reload");
  263.          }
  264.       }
  265.    }
  266. };
  267. this.launcher.onKeyDown = function()
  268. {
  269.    var t = this;
  270.    var p = t._parent;
  271.    if(p.gamePlay == true)
  272.    {
  273.       if(p.gameType == "real")
  274.       {
  275.          if(Key.isDown(p.pKey))
  276.          {
  277.             if(p.pause == false)
  278.             {
  279.                p.pauseFunc(true);
  280.             }
  281.             else
  282.             {
  283.                p.pauseFunc(false);
  284.             }
  285.          }
  286.       }
  287.    }
  288.    if(p.typing == false)
  289.    {
  290.       if(Key.isDown(p.mKey))
  291.       {
  292.          if(p.globalsoundcontrol == "play")
  293.          {
  294.             p.globalsoundcontrol = "stop";
  295.             p.fade = "out";
  296.          }
  297.          else if(p.globalsoundcontrol == "stop")
  298.          {
  299.             p.globalsoundcontrol = "play";
  300.             p.fade = "in";
  301.          }
  302.          if(p.selectPlayer == false)
  303.          {
  304.             p.updateMusic();
  305.          }
  306.          else
  307.          {
  308.             p.updateBeginMusic();
  309.          }
  310.          p.mainDisplay.setSoundText();
  311.       }
  312.    }
  313.    if(p.typing == false)
  314.    {
  315.       if(Key.isDown(p.sKey))
  316.       {
  317.          if(p.soundPlay == "true")
  318.          {
  319.             p.soundPlay = "false";
  320.          }
  321.          else
  322.          {
  323.             p.soundPlay = "true";
  324.          }
  325.          if(p.selectPlayer == false)
  326.          {
  327.             p.updateSound();
  328.          }
  329.          else
  330.          {
  331.             p.updateBeginSounds();
  332.          }
  333.          p.mainDisplay.setSoundText();
  334.       }
  335.    }
  336.    d = p.mainDisplay;
  337.    if(d.selectkey == true)
  338.    {
  339.       d.selectkey = false;
  340.       pressed = Key.getCode();
  341.       p[d.whichkey] = pressed;
  342.       d.setValues(pressed,d.whichkey);
  343.    }
  344.    if(d.userNameGuide.text != "")
  345.    {
  346.       if(Key.isDown(13))
  347.       {
  348.          d.userNameInst.text = d.userNameGuide.text;
  349.          d.userNameGuide.text = "";
  350.          d.accept = "";
  351.       }
  352.    }
  353. };
  354. this.launcher.onKeyUp = function()
  355. {
  356.    var t = this;
  357.    var p = t._parent;
  358.    if(p.logIn == true)
  359.    {
  360.       if(p.typing == true)
  361.       {
  362.          if(p.typeName == true)
  363.          {
  364.             var len = d.userNameInst.text.length;
  365.             if(len > 0)
  366.             {
  367.                var i = 0;
  368.                while(i < p.backUpAccountsA.length)
  369.                {
  370.                   var name = p.backUpAccountsA[i][0];
  371.                   var parName = name.substring(0,len);
  372.                   trace("length: " + len);
  373.                   trace("text within textbox: " + d.userNameInst.text);
  374.                   trace("partial name: " + parName);
  375.                   if(parName == d.userNameInst.text and len != name.length)
  376.                   {
  377.                      trace("Found Name: " + name);
  378.                      d.userNameGuide.text = name;
  379.                      d.accept = "Press ENTER to accept name";
  380.                      break;
  381.                   }
  382.                   d.userNameGuide.text = "";
  383.                   d.accept = "";
  384.                   i++;
  385.                }
  386.             }
  387.             else
  388.             {
  389.                d.userNameGuide.text = "";
  390.                d.accept = "";
  391.             }
  392.          }
  393.       }
  394.    }
  395. };
  396. Key.addListener(this.launcher);
  397.